//
//  ComplainCell.m
//  PropertyMananger
//
//  Created by Mansion on 17/1/16.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "ComplainCell.h"

@implementation ComplainCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"repairDetailCellID";
    ComplainCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[ComplainCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.complainCodeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.complainCodeLabel];
        
        self.complainCodeLabel.textColor = BHColor(51, 51, 51);
        self.complainCodeLabel.textAlignment = NSTextAlignmentLeft;
        self.complainCodeLabel.font = BHFont(15);
        self.complainCodeLabel.text = @"投诉编号：2323434343433";
        
        [self.complainCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(self).with.offset(12.5);
            make.height.mas_equalTo(25);
        }];
        
//        self.iconImg = [[UIImageView alloc]init];
//        [self.contentView addSubview:self.iconImg];
//        self.iconImg.image = IMG(@"ico_new");
//        
//        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.leading.equalTo(self.complainCodeLabel.mas_trailing).with.offset(0);
//            make.top.equalTo(self.complainCodeLabel).with.offset(5);
//            make.height.mas_equalTo(18);
//        }];
        
        self.orderProgressLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.orderProgressLable];
        
        [self.orderProgressLable mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.leading.equalTo(self.complainCodeLabel.mas_trailing).with.offset(10);
            make.centerY.equalTo(self.complainCodeLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(40, 25));
        }];
        
        //     self.orderProgressLable.textColor = BHColor(215, 152, 2);
        self.orderProgressLable.textAlignment = NSTextAlignmentCenter;
        self.orderProgressLable.font = BHFont(10);
        self.orderProgressLable.text  = @"待处理";
        //   self.orderProgressLable.backgroundColor = BHRandColor;
        
        self.orderProgressLable.layer.cornerRadius = 3;
        self.orderProgressLable.layer.masksToBounds = YES;
        self.orderProgressLable.layer.borderWidth = 0.5;
        //   self.orderProgressLable.layer.borderColor = [UIColor greenColor].CGColor;
        
        UIImageView * arrowImg = [[UIImageView alloc]init];
        [self.contentView addSubview:arrowImg];
        arrowImg.image = IMG(@"ico_work_order_next");
        
        [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self).with.offset(-15);
            make.centerY.equalTo(self.orderProgressLable).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(8, 14));
        }];
        
        UIView * lineView = [[UIView alloc]init];
        [self.contentView addSubview:lineView];
        
        lineView.backgroundColor = BHColor(230, 230, 230);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 1));
            make.top.equalTo(self.complainCodeLabel.mas_bottom).with.offset(12.5);
        }];
        //投诉人
        UIImageView * complianManIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:complianManIcon];
        complianManIcon.image = IMG(@"ico_repair_people");
        
        [complianManIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(lineView).with.offset(15);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * complianManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:complianManLabel];
        
        complianManLabel.textColor = BHColor(102, 102, 102);
        complianManLabel.textAlignment = NSTextAlignmentLeft;
        complianManLabel.font = BHFont(15);
        complianManLabel.text  = @"投诉人:";
        
        [complianManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianManIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(complianManIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(60, 25));
        }];
        
        self.complianManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.complianManLabel];
        
        self.complianManLabel.textColor = BHColor(51, 51, 51);
        self.complianManLabel.textAlignment = NSTextAlignmentLeft;
        self.complianManLabel.font = BHFont(15);
        self.complianManLabel.text  = @"吴敏";
       // self.complianManLabel.backgroundColor = BHRandColor;
        
        [self.complianManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianManLabel.mas_trailing).with.offset(0);
            make.top.equalTo(complianManLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2, 25));
        }];
        
       //投诉时间
        UIImageView * complianTimeIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:complianTimeIcon];
        complianTimeIcon.image = IMG(@"ico_repair_time");
        
        [complianTimeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(complianManIcon.mas_bottom).with.offset(30);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * complianTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:complianTimeLabel];
        
        complianTimeLabel.textColor = BHColor(102, 102, 102);
        complianTimeLabel.textAlignment = NSTextAlignmentLeft;
        complianTimeLabel.font = BHFont(15);
        complianTimeLabel.text  = @"投诉时间:";
        
        [complianTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianTimeIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(complianTimeIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.timeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.timeLabel];
        
        self.timeLabel.textColor = BHColor(51, 51, 51);
        self.timeLabel.textAlignment = NSTextAlignmentLeft;
        self.timeLabel.font = BHFont(15);
        self.timeLabel.text  = @"2017-01-01日 (星期天) 15:00";
     //   self.timeLabel.backgroundColor = BHRandColor;
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianTimeLabel.mas_trailing).with.offset(5);
            make.top.equalTo(complianTimeLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2+50, 25));
        }];

        //投诉内容
        UIImageView * contentIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:contentIcon];
        contentIcon.image = IMG(@"ico_repair_type");
        
        [contentIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(complianTimeIcon.mas_bottom).with.offset(30);
           make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * contentLabel = [[UILabel alloc]init];
        [self.contentView addSubview:contentLabel];
        
        contentLabel.textColor = BHColor(102, 102, 102);
        contentLabel.textAlignment = NSTextAlignmentLeft;
        contentLabel.font = BHFont(15);
        contentLabel.text  = @"投诉内容:";
        
        [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(contentIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(contentIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.contentLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.contentLabel];
        
        self.contentLabel.textColor = BHColor(51, 51, 51);
        self.contentLabel.textAlignment = NSTextAlignmentLeft;
        self.contentLabel.font = BHFont(15);
        self.contentLabel.numberOfLines = 0;
//        self.contentLabel.backgroundColor = BHRandColor;
        self.contentLabel.text  = @"投诉内容:小区垃圾桶顺坏，没人来修喂！小区垃圾桶顺坏，没人来修喂！小区垃圾桶顺坏，没人来修喂！小区垃圾桶顺坏，没人来修喂！小区垃圾桶顺坏，没人来修喂！";
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.leading.equalTo(contentLabel.mas_trailing).with.offset(0);
//            make.top.equalTo(contentLabel).with.offset(-5);
//            make.size.mas_equalTo(CGSizeMake(BHscreenW - 120, 70));
            make.leading.equalTo(contentLabel.mas_trailing).with.offset(5);
            make.centerY.equalTo(contentLabel).with.offset(0);
             make.size.mas_equalTo(CGSizeMake(BHscreenW - 130, 25));
        }];


        
    }
    return self;
}
- (void)setModel:(ComplainModel *)model{


    _model = model;
    
    self.contentLabel.text = model.Contents;
    
    if ([model.ComplaintsProcessState isEqualToString:@"10"]) {
        
        self.orderProgressLable.text = @"待处理";
        self.orderProgressLable.textColor = [UIColor redColor];
        self.orderProgressLable.layer.borderColor = [UIColor redColor].CGColor;
        
    }else if ([model.ComplaintsProcessState isEqualToString:@"20"]){
        
        self.orderProgressLable.text = @"处理中";
        self.orderProgressLable.textColor = BHColor(215, 152, 2);
        self.orderProgressLable.layer.borderColor = BHColor(215, 152, 2).CGColor;
        
    }else if ([model.ComplaintsProcessState isEqualToString:@"30"]){
        self.orderProgressLable.text = @"已处理";
        self.orderProgressLable.textColor = BHColor(17, 177, 31);
        self.orderProgressLable.layer.borderColor = BHColor(17, 177, 31).CGColor;
    }else if ([model.ComplaintsProcessState isEqualToString:@"40"]){
        self.orderProgressLable.text = @"已回访";
        self.orderProgressLable.textColor = BHColor(1, 181, 151);
        self.orderProgressLable.layer.borderColor = BHColor(1, 181, 151).CGColor;
    }else if ([model.ComplaintsProcessState isEqualToString:@"50"]){
        self.orderProgressLable.text = @"完成";
        self.orderProgressLable.textColor = [UIColor redColor];
        self.orderProgressLable.layer.borderColor =[UIColor redColor].CGColor;
    }


}
@end
